<template>
  <view>
    <image src="/static/icon_icbd-1.png" class="w100 h100vh absolute" mode=""></image>
    <view class="w100 rowscl rowsm relative">
      <uni-status-bar></uni-status-bar>
      <image src="/static/wd_gr.png" class="w-160 h-160 mt-100 mb-100" mode=""></image>
      <view class="w-690 h-608 br-40 rowscl rowsm" style="background-color: rgba(255, 255, 255, .28);">
        <!-- <view class="w-610 h-100 br-20 bgff pl-30 pr-30 mb-32">
          <picker mode="selector" :range="schoolList" @change="">
            <view class="w100 rowsb rowsm h-100">
              <input type="text" placeholder="请选择您的学校" disabled placeholder-class="fs-28 col333">
              <image src="/static/icon_scc-1.png" class="w-28 h-28" mode=""></image>
            </view>
          </picker>
        </view> -->
        <view class="w-610 h-100 br-20 bgff rowsb rowsm pl-30 pr-22 mb-32">
          <input type="number" placeholder="请输入学号" placeholder-class="fs-28 col333" v-model="studentID">
        </view>
        <view class="w-610 h-100 br-20 bgff rows rowsm pl-30 pr-30 mb-100">
          <input type="text" password placeholder="请输入密码" placeholder-class="fs-28 col333" v-model="password">
        </view>
        <view class="w-610 h-100 rowsc rowsm colfff fw-b fs-32 br-50 mb-28" style="background: linear-gradient(to bottom,#4897FF,#4878FF);" @click="login()">登录</view>
        <!-- <view class="w100 rows rowsm pl-40 pr-40 fs-26" style="flex-direction: row-reverse;color: #888;" @click="$tools.goNext('/pages/login/forget')">忘记密码？</view> -->
      </view>
    </view>
    
    <view class="w100 rowscl rowsm fixed" style="bottom: 60rpx;">
      <view class="rows rowsm mb-22">
        <radio value="r1" :checked="isAgree"   @click="isAgree = !isAgree"/>
        <view class="fs-24 col888">已阅读并同意 
          <text style="color: #4878FF;" @click="toPage('1')">《用户协议》</text> 
          <text style="color: #4878FF;" @click="toPage('2')">《隐私协议》</text> 
        </view>
      </view>
      <view class="fs-24 col333">技术支持由山东风正信息科技有限公司提供</view>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        isAgree:false,
        schoolList:[],
        password:'',
        studentID:''
      };
    },
    onLoad() {
      if(uni.getStorageSync('token')){
        uni.switchTab({
          url:'/pages/index/index'
        })
      }
    },
    methods:{
      // @click="$tools.goNext('/pages/login/agreement?type=1')"
      toPage(type){
        uni.navigateTo({
          url:'/pages/login/agreement?type='+type
        })
      },
      login(){
        if(!this.isAgree) return this.$tools.showtt('请阅读并同意协议')
        if(!this.studentID) return this.$tools.showtt('请输入学号')
        if(!this.password) return this.$tools.showtt('请输入密码')
        this.$tools.axiosFromToken('POST','login/login',{stNumber:this.studentID,password:this.password},'加载中').then(res => {
          if(res.code != 200) return this.$tools.showtt(res.msg)
          let {data:{token}} = res
          uni.setStorageSync('token',token)
          uni.switchTab({
            url:'/pages/index/index'
          })
        })
      }
    }
  }
</script>

<style lang="scss">

</style>
